// 导入axios
import axios from 'axios'
import {useUserStore} from "../stores/userstore";
// 创建 request 实例
const request = axios.create({
  baseURL: 'http://127.0.0.1:8081/'
})

// 请求-拦截器
request.interceptors.request.use(
  (config) => {
    const store=useUserStore()
    config.headers.satoken =store.token
    return config
  },
  (error) => Promise.reject(error)
)
// 响应-拦截器
request.interceptors.response.use(
  (response) => {
    return response.data
  },
  (error) => Promise.reject(error)
)



// 导出
export default request
